import { ajaxTcbCloud } from "@/utils/cloud";
import { successResponseType, failRejectType } from "CustomTypes";

/**
 * 获取留言板信息
 */
export const reqGetMessageBoard = (
  page = 1,
  size = 20
): Promise<successResponseType | failRejectType> =>
  ajaxTcbCloud("/go/getMessageBoard", { page, size });

/**
 * 更新留言板的状态
 */
export const reqUpdateMessageBoardStatus = (_id: string, status: any) =>
  ajaxTcbCloud("/go/updateMessageBoardStatus", { _id, status }, false);

/**
 * 搜索留言板分页列表
 *
 * 已经移植到云函数
 * @param page
 * @param size
 * @param searchType
 * @param searchKeyWord
 */
export const reqSearchMessageBoard = ({
  page,
  size,
  searchType,
  searchKeyWord,
  status
}: any) =>
  ajaxTcbCloud("/go/getMessageBoard", {
    page,
    size,
    [searchType]: searchKeyWord,
    status
  });
